import {
	getDict
} from "@/api/login.js"

export function dictFun(value, res) { //年限
	let string = ""
	let arr = []
	if (res == "requirements_years") {
		arr = uni.getStorageSync("requirements_years")
	} else if (res == "education") {
		arr = uni.getStorageSync("education")
	} else if (res == "company_type") {
		arr = uni.getStorageSync("company_type")
	} else if (res == "company_size") {
		arr = uni.getStorageSync("company_size")
	} else if (res == "company_industry") {
		arr = uni.getStorageSync("company_industry")
	} else if (res == "position_nature") {
		arr = uni.getStorageSync("position_nature")
	} else if (res == "welfare_treatment") { //职位性质
		arr = uni.getStorageSync("welfare_treatment")
	} else if (res == "sys_yes_no") { //
		arr = uni.getStorageSync("sys_yes_no")
	} else if (res == "sys_user_sex") {
		arr = uni.getStorageSync("sys_user_sex")
	} else if (res == "key_population_information") {
		arr = uni.getStorageSync("key_population_information")
	} else if (res == "marriage") {
		arr = uni.getStorageSync("marriage")
	} else if (res == "position_nature") {
		arr = uni.getStorageSync("position_nature")
	} else if (res == "salary") {
		arr = uni.getStorageSync("salary")
	} else if (res == "arrival_time") {
		arr = uni.getStorageSync("arrival_time")
	} else if (res == "status_of_job_hunting") {
		arr = uni.getStorageSync("status_of_job_hunting")
	} else if (res == "proficiency_level") {
		arr = uni.getStorageSync("proficiency_level")
	} else if (res == "political_outlook") {
		arr = uni.getStorageSync("political_outlook")
	} else if (res == "interview_type") {
		arr = uni.getStorageSync("interview_type")
	}else if(res=='sys_certificate_type'){
		arr = uni.getStorageSync("sys_certificate_type")
	}else if(res=='work_nature'){
		arr = uni.getStorageSync("work_nature")
	}
	for (let i = 0; i < arr.length; i++) {
		if (value == arr[i].dictValue) {
			string = arr[i].dictLabel
		}
	}
	return string
}


const that = this
export function dictFunAll() {
	getDict().then(res => {
		console.log("全部字典数据", res);
		sessionStorage.setItem("dictData", JSON.stringify(res.data))
	})
}

export function dictSect(res) {
	const dictDatas = JSON.parse(sessionStorage.getItem("dictData")) || []
	let array = []
	dictDatas.forEach(element => {
		if (element.dictType == res) {
			array = element.dictDataList
		}
	});
	return array
}

export function dictFuns(value, res) {
	const dictDatas = JSON.parse(sessionStorage.getItem("dictData")) || []
	// console.log(value,dictDatas[res]);
	let string = ""
	dictDatas.forEach(element => {
		if (element.dictType == res) {
			element.dictDataList.forEach(element => {
				if (value == element.dictValue) {
					string = element.dictLabel
				}
			})
		}
	});
	return string
}
